;(function($) {
  $(function(){
      $('#J_orderList').removeClass('dn');
      var vm = new Vue({
        el: '#J_orderList',
        data: function() {
          return {
            currentTab: -1,
            shop_id: '',
            list: [],
            lock: false
          }
        },
        created: function() {
          var shop_id = $.getQueryString('shop_id') || ''
          var _this = this;
          _this.shop_id = shop_id;
          _this.currentTab = -1;
          _this.getOrderList()
        },
        filters: {
          hideTelNumber: function(tel) {
            if (tel) {
              return tel.substr(0, 3) + '****' + tel.substr(7, 11)
            } else {
              return ''
            }            
          }
        },
        methods: {      
          getOrderList: function(type) {
            var type = (type !== 0 && type !== 1) ? -1 : type
            var _this = this;
            $.mAjax({
              url: '/order/get-order-list-by-manager',
              data: {type: type},
              success: function(res) {
                if (res.status == 1) {
                  _this.list = res.data              
                } else {
                  if (res.error.errorno == '401') {
                    layer.open({
                      content: '登录过期，请重新登录！',
                      skin: 'msg',
                      time: 2 //2秒后自动关闭
                    })
                    setTimeout(function () {
                      localStorage.removeItem('_u_info_')
                      location.href = './index.html'
                    }, 2000)
                  }
                }
                _this.lock = false
              }
            })
          },
          changeTabHandler: function(tab) {
            if (!this.lock) {
              this.currentTab = tab
              this.lock = true
              this.getOrderList(tab)
            }        
          }
        }
      })
  })    
})(jQuery)